Skip to content

improvement(offering): make network mode mandatory when creating vpc … - #13622

Open
Chinmay048 wants to merge 4 commits into
apache:mainfrom
Chinmay048:fix/13607-validate-network-mode-offerings
Open

Chinmay048 wants to merge 4 commits into
apache:mainfrom
Chinmay048:fix/13607-validate-network-mode-offerings

Conversation

@Chinmay048

Copy link
Copy Markdown
Contributor

Description

This PR resolves an issue where the networkmode parameter (ROUTED vs NATTED) was treated as optional during the creation of VPC and Network Offerings, leading to ambiguous network configurations.

Full-Stack Boundary Enforcement:

  • Frontend (Vue.js / Ant Design): Added reactive validation rules (required: true) in AddVpcOffering.vue and AddNetworkOffering.vue to give administrators immediate visual feedback and prevent form submission if a network mode is not selected.
  • Backend (Java API): Hardened the serialization contract by adding required = true to the @Parameter annotation in CreateVPCOfferingCmd.java and NetworkOfferingBaseCmd.java (which governs creation and cloning operations without impacting updates).

Types of changes

  • Improvement (non-breaking change which enhances UX and API stability)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • My changes generate no new warnings or checkstyle errors.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to eliminate ambiguous VPC/Network Offering configurations by making networkmode (ROUTED vs NATTED) mandatory at both the UI form-validation layer and the Java API parameter layer.

Changes:

  • Added Ant Design Vue form rules to require networkmode selection in the VPC Offering and Network Offering creation UIs.
  • Marked networkmode as required = true in the Java API command parameter annotations for VPC and Network offering creation flows.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
ui/src/views/offering/AddVpcOffering.vue Adds a required validation rule for networkmode in the VPC offering creation form.
ui/src/views/offering/AddNetworkOffering.vue Adds a required validation rule for networkmode in the network offering creation form.
api/src/main/java/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java Sets networkmode as required in the API command parameter definition for VPC offering creation (currently impacts clone as well via inheritance).
api/src/main/java/org/apache/cloudstack/api/command/admin/network/NetworkOfferingBaseCmd.java Sets networkmode as required in the shared base command for network offering create/clone (currently impacts clone as well via inheritance).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +369 to +370
// ADD THIS LINE:
networkmode: [{ required: true, message: this.$t('message.error.select') }],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes sense as well @Chinmay048 , can you apply?

Comment on lines +714 to +715
// ADD THIS LINE:
networkmode: [{ required: true, message: this.$t('message.error.select') }],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this

Comment on lines 147 to 148
@Parameter(name = ApiConstants.NETWORK_MODE, type = CommandType.STRING, required = true, description = "the network mode for the VPC offering")
private String networkMode;
Comment on lines +156 to +157
@Parameter(name = ApiConstants.NETWORK_MODE, type = CommandType.STRING, required = true, description = "the network mode for the network offering")
private String networkMode;

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove the possible values from the descriptions of the networkMode parameters?

@codecov

codecov Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.64%. Comparing base (0e43c6a) to head (6179cb7).
⚠️ Report is 279 commits behind head on main.

Files with missing lines Patch % Lines
...ain/java/com/cloud/network/vpc/VpcManagerImpl.java 50.00% 0 Missing and 2 partials ⚠️
.../cloud/configuration/ConfigurationManagerImpl.java 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #13622      +/-   ##
============================================
+ Coverage     19.50%   19.64%   +0.14%     
- Complexity    19444    19784     +340     
============================================
  Files          6303     6368      +65     
  Lines        569286   574885    +5599     
  Branches      69791    70353     +562     
============================================
+ Hits         111040   112949    +1909     
- Misses       446093   449661    +3568     
- Partials      12153    12275     +122     
Flag Coverage Δ
uitests 3.41% <ø> (-0.01%) ⬇️
unittests 20.92% <62.50%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI review requested due to automatic review settings July 24, 2026 10:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Chinmay048

Copy link
Copy Markdown
Contributor Author

@DaanHoogland Thanks for the guidance! I've added the required unit tests to cover the mandatory networkMode validation, verifying that the proper exception is thrown when the parameter is null or empty.

Additionally, I have restored and properly scoped the API parameter descriptions for both the VPC and Network offerings that were unintentionally altered during the required flag update. Everything is compiling cleanly and passing unit tests on my end please let me know if this is ready for a merge!

description = "Indicates the mode with which the network will operate. Valid option: NATTED or ROUTED",
since = "4.20.0")
private String networkMode;
@Parameter(name = ApiConstants.NETWORK_MODE, type = CommandType.STRING, required = true, description = "the network mode for the network offering")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you should also put back the possible values and in addition to that the since parameter. as well as in CreateVPCOffering.

Comment on lines +45 to +163
@Parameter(name = ApiConstants.INTERNET_PROTOCOL,
type = CommandType.STRING,
description = "The internet protocol of network offering. Options are IPv4 and dualstack. Default is IPv4. dualstack will create a network offering that supports both IPv4 and IPv6",
since = "4.17.0")
private String internetProtocol;

@Parameter(name = ApiConstants.SUPPORTED_SERVICES,
type = CommandType.LIST,
collectionType = CommandType.STRING,
description = "Services supported by the network offering")
private List<String> supportedServices;

@Parameter(name = ApiConstants.SERVICE_PROVIDER_LIST,
type = CommandType.MAP,
description = "Provider to service mapping. If not specified, the provider for the service will be mapped to the default provider on the physical network")
private Map serviceProviderList;

@Parameter(name = ApiConstants.SERVICE_CAPABILITY_LIST, type = CommandType.MAP, description = "Desired service capabilities as part of network offering")
private Map serviceCapabilitystList;

@Parameter(name = ApiConstants.SPECIFY_IP_RANGES,
type = CommandType.BOOLEAN,
description = "True if network offering supports specifying ip ranges; defaulted to false if not specified")
private Boolean specifyIpRanges;

@Parameter(name = ApiConstants.IS_PERSISTENT,
type = CommandType.BOOLEAN,
description = "True if network offering supports persistent networks; defaulted to false if not specified")
private Boolean isPersistent;

@Parameter(name = ApiConstants.FOR_VPC,
type = CommandType.BOOLEAN,
description = "True if network offering is meant to be used for VPC, false otherwise.")
private Boolean forVpc;

@Parameter(name = ApiConstants.FOR_NSX,
type = CommandType.BOOLEAN,
description = "true if network offering is meant to be used for NSX, false otherwise.",
since = "4.20.0")
private Boolean forNsx;

@Parameter(name = ApiConstants.NSX_SUPPORT_LB,
type = CommandType.BOOLEAN,
description = "True if network offering for NSX network offering supports Load balancer service.",
since = "4.20.0")
private Boolean nsxSupportsLbService;

@Parameter(name = ApiConstants.NSX_SUPPORTS_INTERNAL_LB,
type = CommandType.BOOLEAN,
description = "True if network offering for NSX network offering supports Internal Load balancer service.",
since = "4.20.0")
private Boolean nsxSupportsInternalLbService;

@Parameter(
name = ApiConstants.NETWORK_MODE,
type = CommandType.STRING,
required = true,
description = "the network mode of the network offering, possible values are NATTED and ROUTED"
)
private String networkMode;

@Parameter(name = ApiConstants.FOR_TUNGSTEN,
type = CommandType.BOOLEAN,
description = "True if network offering is meant to be used for Tungsten-Fabric, false otherwise.")
private Boolean forTungsten;

@Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, since = "4.2.0", description = "Network offering details in key/value pairs."
+ " Supported keys are internallbprovider/publiclbprovider with service provider as a value, and"
+ " promiscuousmode/macaddresschanges/forgedtransmits with true/false as value to accept/reject the security settings if available for a nic/portgroup")
protected Map details;

@Parameter(name = ApiConstants.EGRESS_DEFAULT_POLICY,
type = CommandType.BOOLEAN,
description = "True if guest network default egress policy is allow; false if default egress policy is deny")
private Boolean egressDefaultPolicy;

@Parameter(name = ApiConstants.KEEPALIVE_ENABLED,
type = CommandType.BOOLEAN,
required = false,
description = "If true keepalive will be turned on in the loadbalancer. At the time of writing this has only an effect on haproxy; the mode http and httpclose options are unset in the haproxy conf file.")
private Boolean keepAliveEnabled;

@Parameter(name = ApiConstants.MAX_CONNECTIONS,
type = CommandType.INTEGER,
description = "Maximum number of concurrent connections supported by the Network offering")
private Integer maxConnections;

@Parameter(name = ApiConstants.DOMAIN_ID,
type = CommandType.LIST,
collectionType = CommandType.UUID,
entityType = DomainResponse.class,
description = "The ID of the containing domain(s), null for public offerings")
private List<Long> domainIds;

@Parameter(name = ApiConstants.ZONE_ID,
type = CommandType.LIST,
collectionType = CommandType.UUID,
entityType = ZoneResponse.class,
description = "The ID of the containing zone(s), null for public offerings",
since = "4.13")
private List<Long> zoneIds;

@Parameter(name = ApiConstants.ENABLE,
type = CommandType.BOOLEAN,
description = "Set to true if the offering is to be enabled during creation. Default is false",
since = "4.16")
private Boolean enable;

@Parameter(name = ApiConstants.SPECIFY_AS_NUMBER, type = CommandType.BOOLEAN, since = "4.20.0",
description = "true if network offering supports choosing AS number")
private Boolean specifyAsNumber;

@Parameter(name = ApiConstants.ROUTING_MODE,
type = CommandType.STRING,
since = "4.20.0",
description = "the routing mode for the network offering. Supported types are: Static or Dynamic.")
private String routingMode;


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next make sure all annotations in have a since parameter in ``CreateNetworkOffering` containing "4.24.0” , the expected version to add this PR to.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, having a second look at this change I am not so sure about it anymore.
CC/can you have a look @weizhouapache @vishesh92 ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not make API changes !!!

@DaanHoogland

Copy link
Copy Markdown
Contributor

@Chinmay048 , I don’t think this will make it in. adding required parameters is not desirable. Better give them reasonable defaults. Also the list of extra parameters in CreateNetworkOfferingCmd seems excessive. Care to revisit this?

Copilot AI review requested due to automatic review settings July 27, 2026 14:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@DaanHoogland DaanHoogland moved this from Backlog to Ready in CloudStack Testing Aug 31, 2026
@DaanHoogland DaanHoogland assigned abh1sar and unassigned abh1sar Sep 1, 2026
@DaanHoogland DaanHoogland moved this from Ready to conflict/waiting in CloudStack Testing Sep 1, 2026
@nvazquez nvazquez added this to the 24.0 milestone Oct 29, 2026
@nvazquez

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✖️ debian ✔️ suse15. SL-JID 19817

@nvazquez

nvazquez commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-17518)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 64617 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13622-t17518-kvm-ol8.zip
Smoke tests completed. 112 look OK, 45 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_01_events_resource Error 0.27 test_events_resource.py
ContextSuite context=TestExtensions>:setup Error 0.00 test_extension_custom.py
ContextSuite context=TestClusterDRS>:setup Error 0.00 test_cluster_drs.py
test_01_internallb_roundrobin_1VPC_3VM_HTTP_port80 Failure 1.40 test_internal_lb.py
test_02_internallb_roundrobin_1RVPC_3VM_HTTP_port80 Failure 1.42 test_internal_lb.py
test_03_vpc_internallb_haproxy_stats_on_all_interfaces Failure 2.66 test_internal_lb.py
test_04_rvpc_internallb_haproxy_stats_on_all_interfaces Failure 3.95 test_internal_lb.py
test_08_vpc_and_tier_failed_cases Error 2.34 test_ipv4_routing.py
test_01_create_ipv6_network_offering Error 0.16 test_ipv6_infra.py
test_02_create_ipv6_network_offering_fail Error 0.04 test_ipv6_infra.py
ContextSuite context=TestDirectDownloadTemplates>:setup Error 0.00 test_direct_download.py
test_01_create_network_offering Error 0.01 test_domain_network_offerings.py
ContextSuite context=TestDomainsNetworkOfferings>:setup Error 3.62 test_domain_network_offerings.py
test_04_validate_vpc_offering_conserve_mode_disabled Error 208.13 test_domain_vpc_offerings.py
test_09_extension_deploy_vm Error 18.83 test_extension_lifecycle.py
test_uservm_host_control_state Failure 17.17 test_host_control_state.py
test_10_vpc_tier_kubernetes_cluster Error 77.04 test_kubernetes_clusters.py
test_01_nic Error 25.84 test_nic.py
ContextSuite context=TestNetworkMigration>:setup Error 0.00 test_migration.py
ContextSuite context=TestAdapterTypeForNic>:setup Error 0.00 test_nic_adapter_type.py
ContextSuite context=TestNestedVirtualization>:setup Error 0.00 test_nested_virtualization.py
test_04_dhcp_dns_userdata Error 3.11 test_network_extension_namespace.py
test_05_isolated_network_full_lifecycle Error 2.76 test_network_extension_namespace.py
test_06_vpc_multi_tier_and_restart Error 2.76 test_network_extension_namespace.py
test_07_vpc_network_acl Error 3.19 test_network_extension_namespace.py
test_08_custom_action_policy_based_routing Error 4.75 test_network_extension_namespace.py
test_09_vpc_source_nat_ip_update Error 7.89 test_network_extension_namespace.py
test_10_vpc_custom_action_policy_based_routing Error 3.26 test_network_extension_namespace.py
test_11_ipv6_dualstack_isolated_network Error 4.80 test_network_extension_namespace.py
test_01_verify_ipv6_network Error 2.90 test_network_ipv6.py
ContextSuite context=TestNetworkPermissions>:setup Error 0.00 test_network_permissions.py
ContextSuite context=TestL2Networks>:setup Error 201.62 test_network.py
ContextSuite context=TestPublicIP>:setup Error 9.84 test_network.py
ContextSuite context=TestSharedNetwork>:setup Error 54.87 test_network.py
ContextSuite context=TestSharedNetworkWithConfigDrive>:setup Error 121.47 test_network.py
ContextSuite context=TestNonStrictAffinityGroups>:setup Error 0.00 test_nonstrict_affinity_group.py
ContextSuite context=TestIsolatedNetworksPasswdServer>:setup Error 0.00 test_password_server.py
ContextSuite context=TestL2PersistentNetworks>:setup Error 0.00 test_persistent_network.py
ContextSuite context=TestPortablePublicIPAcquire>:setup Error 0.00 test_portable_publicip.py
test_01_vpc_privategw_acl Failure 80.92 test_privategw_acl.py
test_02_vpc_privategw_static_routes Failure 142.81 test_privategw_acl.py
test_03_vpc_privategw_restart_vpc_cleanup Failure 135.72 test_privategw_acl.py
test_04_rvpc_privategw_static_routes Failure 274.66 test_privategw_acl.py
ContextSuite context=TestPurgeExpungedVms>:setup Error 0.00 test_purge_expunged_vms.py
test_CRUD_operations_userdata Error 20.41 test_register_userdata.py
test_deploy_vm_with_registered_userdata Error 5.51 test_register_userdata.py
test_deploy_vm_with_registered_userdata_with_override_policy_allow Error 4.87 test_register_userdata.py
test_deploy_vm_with_registered_userdata_with_override_policy_append Error 5.13 test_register_userdata.py
test_deploy_vm_with_registered_userdata_with_override_policy_deny Error 5.53 test_register_userdata.py
test_deploy_vm_with_registered_userdata_with_params Error 5.44 test_register_userdata.py
test_link_and_unlink_userdata_to_template Error 5.54 test_register_userdata.py
test_user_userdata_crud Error 4.87 test_register_userdata.py
ContextSuite context=TestRouterDHCPHosts>:setup Error 0.00 test_router_dhcphosts.py
ContextSuite context=TestRouterDHCPOpts>:setup Error 0.00 test_router_dhcphosts.py
ContextSuite context=TestVMWareStoragePolicies>:setup Error 0.00 test_storage_policy.py
ContextSuite context=TestRouterDns>:setup Error 0.00 test_router_dns.py
ContextSuite context=TestRouterDnsService>:setup Error 0.00 test_router_dnsservice.py
test_01_single_VPC_iptables_policies Error 77.68 test_routers_iptables_default_policy.py
test_01_isolate_network_FW_PF_default_routes_egress_true Error 0.00 test_routers_network_ops.py
test_02_isolate_network_FW_PF_default_routes_egress_false Error 0.00 test_routers_network_ops.py
test_01_RVR_Network_FW_PF_SSH_default_routes_egress_true Error 0.00 test_routers_network_ops.py
test_02_RVR_Network_FW_PF_SSH_default_routes_egress_false Error 0.00 test_routers_network_ops.py
test_03_RVR_Network_check_router_state Error 0.00 test_routers_network_ops.py
ContextSuite context=TestSetSourceNatIp>:setup Error 0.00 test_set_sourcenat.py
ContextSuite context=TestSharedFSLifecycle>:setup Error 0.00 test_sharedfs_lifecycle.py
ContextSuite context=TestSslOffloading>:setup Error 0.00 test_ssl_offloading.py
test_3_userdata_on_vr Failure 0.24 test_systemvm_userdata.py
ContextSuite context=TestVmAutoScaling>:setup Error 0.00 test_vm_autoscaling.py
ContextSuite context=TestUnmanageKvmVM>:setup Error 0.00 test_vm_lifecycle_unmanage_kvm_import.py
test_04_deploy_vnf_appliance Error 246.36 test_vnf_templates.py
ContextSuite context=TestVPCConserveModeRules>:setup Error 0.00 test_vpc_conserve_mode.py
test_01_verify_ipv6_vpc Error 99.03 test_vpc_ipv6.py
test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL Failure 226.03 test_vpc_redundant.py
test_02_redundant_VPC_default_routes Failure 178.99 test_vpc_redundant.py
test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers Failure 152.93 test_vpc_redundant.py
test_04_rvpc_network_garbage_collector_nics Failure 151.66 test_vpc_redundant.py
test_05_rvpc_multi_tiers Failure 169.78 test_vpc_redundant.py
test_01_VPC_nics_after_destroy Failure 112.28 test_vpc_router_nics.py
test_02_VPC_default_routes Failure 84.85 test_vpc_router_nics.py
test_02_cancel_host_maintenace_with_migration_jobs Error 0.26 test_host_maintenance.py
test_03_cancel_host_maintenace_with_migration_jobs_failure Failure 0.37 test_host_maintenance.py
ContextSuite context=TestHostMaintenanceAgents>:setup Error 0.60 test_host_maintenance.py

@RosiKyu RosiKyu modified the milestones: 24.0, 25.0 Nov 11, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: conflict/waiting

Development

Successfully merging this pull request may close these issues.

Improvement/Ui: Make network mode mandatory or validate when creating vpc offering and network offering

8 participants